<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=9"/>
<meta name="generator" content="Doxygen 1.9.1"/>
<meta name="viewport" content="width=device-width, initial-scale=1"/>
<title>Eigen: The class hierarchy</title>
<link href="tabs.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript" src="dynsections.js"></script>
<link href="navtree.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="resize.js"></script>
<script type="text/javascript" src="navtreedata.js"></script>
<script type="text/javascript" src="navtree.js"></script>
<link href="search/search.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="search/searchdata.js"></script>
<script type="text/javascript" src="search/search.js"></script>
<script type="text/javascript">
/* @license magnet:?xt=urn:btih:cf05388f2679ee054f2beb29a391d25f4e673ac3&amp;dn=gpl-2.0.txt GPL-v2 */
  $(document).ready(function() { init_search(); });
/* @license-end */
</script>
<script type="text/x-mathjax-config">
  MathJax.Hub.Config({
    extensions: ["tex2jax.js", "TeX/AMSmath.js", "TeX/AMSsymbols.js"],
    jax: ["input/TeX","output/HTML-CSS"],
});
</script>
<script type="text/javascript" async="async" src="https://cdn.mathjax.org/mathjax/latest/MathJax.js"></script>
<link href="doxygen.css" rel="stylesheet" type="text/css" />
<link href="eigendoxy.css" rel="stylesheet" type="text/css">
<!--  -->
<script type="text/javascript" src="eigen_navtree_hacks.js"></script>
</head>
<body>
<div id="top"><!-- do not remove this div, it is closed by doxygen! -->
<div id="titlearea">
<table cellspacing="0" cellpadding="0">
 <tbody>
 <tr style="height: 56px;">
  <td id="projectlogo"><img alt="Logo" src="Eigen_Silly_Professor_64x64.png"/></td>
  <td id="projectalign" style="padding-left: 0.5em;">
   <div id="projectname"><a href="http://eigen.tuxfamily.org">Eigen</a>
   &#160;<span id="projectnumber">3.4.90 (git rev 67eeba6e720c5745abc77ae6c92ce0a44aa7b7ae)</span>
   </div>
  </td>
   <td>        <div id="MSearchBox" class="MSearchBoxInactive">
        <span class="left">
          <img id="MSearchSelect" src="search/mag_sel.svg"
               onmouseover="return searchBox.OnSearchSelectShow()"
               onmouseout="return searchBox.OnSearchSelectHide()"
               alt=""/>
          <input type="text" id="MSearchField" value="Search" accesskey="S"
               onfocus="searchBox.OnSearchFieldFocus(true)" 
               onblur="searchBox.OnSearchFieldFocus(false)" 
               onkeyup="searchBox.OnSearchFieldChange(event)"/>
          </span><span class="right">
            <a id="MSearchClose" href="javascript:searchBox.CloseResultsWindow()"><img id="MSearchCloseImg" border="0" src="search/close.svg" alt=""/></a>
          </span>
        </div>
</td>
 </tr>
 </tbody>
</table>
</div>
<!-- end header part -->
<!-- Generated by Doxygen 1.9.1 -->
<script type="text/javascript">
/* @license magnet:?xt=urn:btih:cf05388f2679ee054f2beb29a391d25f4e673ac3&amp;dn=gpl-2.0.txt GPL-v2 */
var searchBox = new SearchBox("searchBox", "search",false,'Search','.html');
/* @license-end */
</script>
</div><!-- top -->
<div id="side-nav" class="ui-resizable side-nav-resizable">
  <div id="nav-tree">
    <div id="nav-tree-contents">
      <div id="nav-sync" class="sync"></div>
    </div>
  </div>
  <div id="splitbar" style="-moz-user-select:none;" 
       class="ui-resizable-handle">
  </div>
</div>
<script type="text/javascript">
/* @license magnet:?xt=urn:btih:cf05388f2679ee054f2beb29a391d25f4e673ac3&amp;dn=gpl-2.0.txt GPL-v2 */
$(document).ready(function(){initNavTree('TopicClassHierarchy.html',''); initResizable(); });
/* @license-end */
</script>
<div id="doc-content">
<!-- window showing the filter options -->
<div id="MSearchSelectWindow"
     onmouseover="return searchBox.OnSearchSelectShow()"
     onmouseout="return searchBox.OnSearchSelectHide()"
     onkeydown="return searchBox.OnSearchSelectKey(event)">
</div>

<!-- iframe showing the search results (closed by default) -->
<div id="MSearchResultsWindow">
<iframe src="javascript:void(0)" frameborder="0" 
        name="MSearchResults" id="MSearchResults">
</iframe>
</div>

<div class="PageDoc"><div class="header">
  <div class="headertitle">
<div class="title">The class hierarchy </div>  </div>
</div><!--header-->
<div class="contents">
<div class="textblock"><p>This page explains the design of the core classes in <a class="el" href="namespaceEigen.html" title="Namespace containing all symbols from the Eigen library.">Eigen</a>'s class hierarchy and how they fit together. Casual users probably need not concern themselves with these details, but it may be useful for both advanced users and <a class="el" href="namespaceEigen.html" title="Namespace containing all symbols from the Eigen library.">Eigen</a> developers.</p>
<h1><a class="anchor" id="TopicClassHierarchyPrinciples"></a>
Principles</h1>
<p><a class="el" href="namespaceEigen.html" title="Namespace containing all symbols from the Eigen library.">Eigen</a>'s class hierarchy is designed so that virtual functions are avoided where their overhead would significantly impair performance. Instead, <a class="el" href="namespaceEigen.html" title="Namespace containing all symbols from the Eigen library.">Eigen</a> achieves polymorphism with the Curiously Recurring Template Pattern (CRTP). In this pattern, the base class (for instance, <code><a class="el" href="classEigen_1_1MatrixBase.html" title="Base class for all dense matrices, vectors, and expressions.">MatrixBase</a></code>) is in fact a template class, and the derived class (for instance, <code><a class="el" href="classEigen_1_1Matrix.html" title="The matrix class, also used for vectors and row-vectors.">Matrix</a></code>) inherits the base class with the derived class itself as a template argument (in this case, <code><a class="el" href="classEigen_1_1Matrix.html" title="The matrix class, also used for vectors and row-vectors.">Matrix</a></code> inherits from <code><a class="el" href="classEigen_1_1MatrixBase.html" title="Base class for all dense matrices, vectors, and expressions.">MatrixBase</a>&lt;<a class="el" href="classEigen_1_1Matrix.html" title="The matrix class, also used for vectors and row-vectors.">Matrix</a>&gt;</code>). This allows <a class="el" href="namespaceEigen.html" title="Namespace containing all symbols from the Eigen library.">Eigen</a> to resolve the polymorphic function calls at compile time.</p>
<p>In addition, the design avoids multiple inheritance. One reason for this is that in our experience, some compilers (like MSVC) fail to perform empty base class optimization, which is crucial for our fixed-size types.</p>
<h1><a class="anchor" id="TopicClassHierarchyCoreClasses"></a>
The core classes</h1>
<p>These are the classes that you need to know about if you want to write functions that accept or return <a class="el" href="namespaceEigen.html" title="Namespace containing all symbols from the Eigen library.">Eigen</a> objects.</p>
<ul>
<li><a class="el" href="classEigen_1_1Matrix.html" title="The matrix class, also used for vectors and row-vectors.">Matrix</a> means plain dense matrix. If <code>m</code> is a <code>Matrix</code>, then, for instance, <code>m+m</code> is no longer a <code>Matrix</code>, it is a "matrix expression".</li>
<li><a class="el" href="classEigen_1_1MatrixBase.html" title="Base class for all dense matrices, vectors, and expressions.">MatrixBase</a> means dense matrix expression. This means that a <code>MatrixBase</code> is something that can be added, matrix-multiplied, LU-decomposed, QR-decomposed... All matrix expression classes, including <code>Matrix</code> itself, inherit <code>MatrixBase</code>.</li>
<li><a class="el" href="classEigen_1_1Array.html" title="General-purpose arrays with easy API for coefficient-wise operations.">Array</a> means plain dense array. If <code>x</code> is an <code>Array</code>, then, for instance, <code>x+x</code> is no longer an <code>Array</code>, it is an "array expression".</li>
<li><a class="el" href="classEigen_1_1ArrayBase.html" title="Base class for all 1D and 2D array, and related expressions.">ArrayBase</a> means dense array expression. This means that an <code>ArrayBase</code> is something that can be added, array-multiplied, and on which you can perform all sorts of array operations... All array expression classes, including <code>Array</code> itself, inherit <code>ArrayBase</code>.</li>
<li><a class="el" href="classEigen_1_1DenseBase.html" title="Base class for all dense matrices, vectors, and arrays.">DenseBase</a> means dense (matrix or array) expression. Both <code>ArrayBase</code> and <code>MatrixBase</code> inherit <code>DenseBase</code>. <code>DenseBase</code> is where all the methods go that apply to dense expressions regardless of whether they are matrix or array expressions. For example, the <a class="el" href="">block(...) </a> methods are in <code>DenseBase</code>.</li>
</ul>
<h1><a class="anchor" id="TopicClassHierarchyBaseClasses"></a>
Base classes</h1>
<p>These classes serve as base classes for the five core classes mentioned above. They are more internal and so less interesting for users of the <a class="el" href="namespaceEigen.html" title="Namespace containing all symbols from the Eigen library.">Eigen</a> library.</p>
<ul>
<li><a class="el" href="classEigen_1_1PlainObjectBase.html" title="Dense storage base class for matrices and arrays.">PlainObjectBase</a> means dense (matrix or array) plain object, i.e. something that stores its own dense array of coefficients. This is where, for instance, the <a class="el" href="classEigen_1_1PlainObjectBase.html#a9fd0703bd7bfe89d6dc80e2ce87c312a">resize() </a> methods go. <code>PlainObjectBase</code> is inherited by <code>Matrix</code> and by <code>Array</code>. But above, we said that <code>Matrix</code> inherits <code>MatrixBase</code> and <code>Array</code> inherits <code>ArrayBase</code>. So does that mean multiple inheritance? No, because <code>PlainObjectBase</code> <em>itself</em> inherits <code>MatrixBase</code> or <code>ArrayBase</code> depending on whether we are in the matrix or array case. When we said above that <code>Matrix</code> inherited <code>MatrixBase</code>, we omitted to say it does so indirectly via <code>PlainObjectBase</code>. Same for <code>Array</code>.</li>
<li>DenseCoeffsBase means something that has dense coefficient accessors. It is a base class for <code>DenseBase</code>. The reason for <code>DenseCoeffsBase</code> to exist is that the set of available coefficient accessors is very different depending on whether a dense expression has direct memory access or not (the <code>DirectAccessBit</code> flag). For example, if <code>x</code> is a plain matrix, then <code>x</code> has direct access, and <code>x.transpose()</code> and <code>x.block(...)</code> also have direct access, because their coefficients can be read right off memory, but for example, <code>x+x</code> does not have direct memory access, because obtaining any of its coefficients requires a computation (an addition), it can't be just read off memory.</li>
<li><a class="el" href="structEigen_1_1EigenBase.html">EigenBase</a> means anything that can be evaluated into a plain dense matrix or array (even if that would be a bad idea). <code>EigenBase</code> is really the absolute base class for anything that remotely looks like a matrix or array. It is a base class for <code>DenseCoeffsBase</code>, so it sits below all our dense class hierarchy, but it is not limited to dense expressions. For example, <code>EigenBase</code> is also inherited by diagonal matrices, sparse matrices, etc...</li>
</ul>
<h1><a class="anchor" id="TopicClassHierarchyInheritanceDiagrams"></a>
Inheritance diagrams</h1>
<p>The inheritance diagram for <a class="el" href="classEigen_1_1Matrix.html" title="The matrix class, also used for vectors and row-vectors.">Matrix</a> looks as follows:</p>
<pre>
<a class="el" href="structEigen_1_1EigenBase.html">EigenBase</a>&lt;Matrix&gt;
  &lt;-- DenseCoeffsBase&lt;Matrix&gt;    (direct access case)
    &lt;-- <a class="el" href="classEigen_1_1DenseBase.html" title="Base class for all dense matrices, vectors, and arrays.">DenseBase</a>&lt;Matrix&gt;
      &lt;-- <a class="el" href="classEigen_1_1MatrixBase.html" title="Base class for all dense matrices, vectors, and expressions.">MatrixBase</a>&lt;Matrix&gt;
        &lt;-- <a class="el" href="classEigen_1_1PlainObjectBase.html" title="Dense storage base class for matrices and arrays.">PlainObjectBase</a>&lt;Matrix&gt;    (matrix case)
          &lt;-- <a class="el" href="classEigen_1_1Matrix.html" title="The matrix class, also used for vectors and row-vectors.">Matrix</a>
</pre><p>The inheritance diagram for <a class="el" href="classEigen_1_1Array.html" title="General-purpose arrays with easy API for coefficient-wise operations.">Array</a> looks as follows:</p>
<pre>
<a class="el" href="structEigen_1_1EigenBase.html">EigenBase</a>&lt;Array&gt;
  &lt;-- DenseCoeffsBase&lt;Array&gt;    (direct access case)
    &lt;-- <a class="el" href="classEigen_1_1DenseBase.html" title="Base class for all dense matrices, vectors, and arrays.">DenseBase</a>&lt;Array&gt;
      &lt;-- <a class="el" href="classEigen_1_1ArrayBase.html" title="Base class for all 1D and 2D array, and related expressions.">ArrayBase</a>&lt;Array&gt;
        &lt;-- <a class="el" href="classEigen_1_1PlainObjectBase.html" title="Dense storage base class for matrices and arrays.">PlainObjectBase</a>&lt;Array&gt;    (array case)
          &lt;-- <a class="el" href="classEigen_1_1Array.html" title="General-purpose arrays with easy API for coefficient-wise operations.">Array</a>
</pre><p>The inheritance diagram for some other matrix expression class, here denoted by <code>SomeMatrixXpr</code>, looks as follows:</p>
<pre>
<a class="el" href="structEigen_1_1EigenBase.html">EigenBase</a>&lt;SomeMatrixXpr&gt;
  &lt;-- DenseCoeffsBase&lt;SomeMatrixXpr&gt;    (direct access or no direct access case)
    &lt;-- <a class="el" href="classEigen_1_1DenseBase.html" title="Base class for all dense matrices, vectors, and arrays.">DenseBase</a>&lt;SomeMatrixXpr&gt;
      &lt;-- <a class="el" href="classEigen_1_1MatrixBase.html" title="Base class for all dense matrices, vectors, and expressions.">MatrixBase</a>&lt;SomeMatrixXpr&gt;
        &lt;-- SomeMatrixXpr
</pre><p>The inheritance diagram for some other array expression class, here denoted by <code>SomeArrayXpr</code>, looks as follows:</p>
<pre>
<a class="el" href="structEigen_1_1EigenBase.html">EigenBase</a>&lt;SomeArrayXpr&gt;
  &lt;-- DenseCoeffsBase&lt;SomeArrayXpr&gt;    (direct access or no direct access case)
    &lt;-- <a class="el" href="classEigen_1_1DenseBase.html" title="Base class for all dense matrices, vectors, and arrays.">DenseBase</a>&lt;SomeArrayXpr&gt;
      &lt;-- <a class="el" href="classEigen_1_1ArrayBase.html" title="Base class for all 1D and 2D array, and related expressions.">ArrayBase</a>&lt;SomeArrayXpr&gt;
        &lt;-- SomeArrayXpr
</pre><p>Finally, consider an example of something that is not a dense expression, for instance a diagonal matrix. The corresponding inheritance diagram is:</p>
<pre>
<a class="el" href="structEigen_1_1EigenBase.html">EigenBase</a>&lt;DiagonalMatrix&gt;
  &lt;-- DiagonalBase&lt;DiagonalMatrix&gt;
    &lt;-- <a class="el" href="classEigen_1_1DiagonalMatrix.html" title="Represents a diagonal matrix with its storage.">DiagonalMatrix</a>
</pre> </div></div><!-- contents -->
</div><!-- PageDoc -->
</div><!-- doc-content -->
<!-- start footer part -->
<div id="nav-path" class="navpath"><!-- id is needed for treeview function! -->
  <ul>
    <li class="footer">Generated on Thu Apr 21 2022 13:07:55 for Eigen by
    <a href="http://www.doxygen.org/index.html">
    <img class="footer" src="doxygen.png" alt="doxygen"/></a> 1.9.1 </li>
  </ul>
</div>
</body>
</html>
